package api

import (
	"feng-che.com/server/driver-quiz/internal"
	"feng-che.com/server/driver-quiz/internal/client"
	"feng-che.com/server/driver-quiz/internal/dep_jwt"
	"feng-che.com/server/driver-quiz/internal/institution"
	"feng-che.com/server/driver-quiz/internal/reserver"
	"feng-che.com/server/driver-quiz/internal/user"
	serverCommon "fiberCommonUtils/common"
	"github.com/gofiber/fiber/v2"
)

func installAdmin(admin fiber.Router) {
	admin.Post("/adminLogin", user.MiddlewareFindUserByLoginName, user.AdminLogin)
	admin.Post("/userLogOut", user.Logout)

	admin.Use("/", dep_jwt.VerifyUserForNext, user.RequiredUserLogin)

	admin.Post("/changePassword", user.ChangePassword)

	///*商品*/
	//admin.Get("/driverServiceName", internal.GetAllDriverServiceNames)
	//admin.Get("/subGoods", internal.ExploreSubjectSpuTypes)
	//admin.Post("/editSubjectServiceSpu", internal.EditSubjectServiceSpu)
	//admin.Get("/loadOneSpuService", internal.AdminGetOneSpuService)
	//admin.Post("/addSkuToSpuService", internal.AddOneSkuServiceToSpuService)
	//admin.Get("/loadSkuOfOneSpu", internal.ReadSkuOfOneSpu)
	//admin.Post("/toggleOnlyBuyForCoach", internal.ToggleForCoach)
	//admin.Post("/rmSub2Models", internal.DeleteSub2Models)
	//admin.Post("/editDriverExamSpu", internal.EditDriverExamSpu)
	//admin.Get("/getAllSpuForAEnterprise", internal.GetAllSpuForEnterprise)
	//admin.Post("/addDriverExamPracticeSpuStock", internal.AddStockOFExamPractice)
	//admin.Post("/changeSpuStock", internal.AdminChangeSpuStockNumber)
	//admin.Post("/editSkuServiceLimitWords", internal.EditLimitWord)
	//admin.Post("/editSkuServiceContainTicket", internal.EditSkuServiceContainTicket)
	//admin.Post("/editSkuServiceBuyForNew", internal.CanNewClientBuyThisSku)
	//admin.Post("/setSkuBuyLimitForDriverStudy", internal.SetSkuServiceOfDriverStudySRestrictions)
	//
	///*票模板*/
	//admin.Get("/allTicket", internal.ExploreTicketTemplate)
	//admin.Post("/editTicketTemplate", internal.EditTicketTemplate)
	//admin.Post("/deleteTicketTemplate", internal.DeleteTicketTemplate)
	//admin.Post("/bindTicketCheckingMachineAndTickets", internal.BindTicketCheckingAndTickets)
	//admin.Post("/setVip", internal.SetVipHandle)
	//
	///* 消费权益 */
	//admin.Post("/editConsumeInterest", internal.EditClientRestrictions)
	//admin.Get("/consumeInterest/ticket/:id", internal.QueryOneTicketTemplateBenefit)
	//
	///* 考场 */
	admin.Get("/allInstitution", institution.SimpleInformationOfInstitutions)
	admin.Get("/allVehicle", institution.SimpleInformationOfVehicle)
	admin.Post("/updateVehicle", institution.CreateVehicle)
	admin.Post("/updateVehicleMachineSN", institution.BindVehicleMachineSN)
	// 驾校
	admin.Get("/allSchool", institution.SimpleInformationOfSchool)
	admin.Post("/updateSchool", internal.CreateSchool)
	admin.Get("/exploreSchoolStaff", internal.ExploreCoach)
	admin.Post("/updateSchoolStaff", internal.CreateCoach)
	admin.Post("/updateSchoolStaffRole", user.MiddlewareFindUserByID, internal.EditUserRoleForSchool)
	//admin.Post("/insertExamArea", internal.CreateOneExamArea)
	//admin.Post("/ExamAreaEditField", internal.EditOneExamAreaField)
	//admin.Post("/ExamAreaAddPhoto/:id", internal.UploadExamAreaImage)
	//admin.Get("/carOfArea", internal.ExploreAreaVehicle)
	//admin.Post("/editVehicle", internal.EditVehicle)
	//服务项目
	admin.Get("/allServices", internal.ExploreServices)
	admin.Post("/editService", internal.CreateService)
	admin.Post("/editServiceDuration", internal.EditServiceDuration)
	admin.Post("/editServiceProfitSharing", internal.EditServiceSharing)
	//
	///* 安全员 */
	//admin.Post("/editGuide", internal.EditGuide)
	//admin.Get("/exploreGuide", internal.ExploreGuide)
	//
	///* 客户 */
	admin.Get("/exploreClients", internal.QueryClient)
	//admin.Get("/queryOneClient", internal.QueryOneClient)
	//admin.Post("/setCoachRole", internal.SetCoachRole)
	//admin.Post("/getManyClientInfoSimple", internal.QuerySimpleClientInfo)
	//admin.Get("/allSchool", client.ReadAllSchool)
	//admin.Post("/editSchool", client.EditSchool)
	//admin.Post("/setCoachWorkSchool", internal.SetCoachWorkInSchool)
	//
	///* 订单管理 */
	//admin.Get("/exploreCoachOrder", internal.ExploreOrderGroupByRole)
	//admin.Get("/exploreSelfOrder", func(c *fiber.Ctx) error {
	//	c.Locals("student", "yes")
	//	return c.Next()
	//}, internal.ExploreOrderGroupByRole)
	//admin.Get("/exploreSoldTicket", internal.ExploreSoldTicket)
	//
	///* 检票 */
	//admin.Get("/queryTicketCheckingMachine", internal.ExploreTicketCheckMachine)
	//admin.Post("/editTicketCheckingMachine", internal.EditTicketCheckMachine)
	//admin.Get("/getLineUpQrcode", internal.GetOneTicketMachineLineUpQrString)
	//admin.Get("/getCheckTicketQrcode", internal.GetTicketMachineCheckingQrString)
	//admin.Get("/currentCallClient", internal.QueryTicketCallingMachineCurrentCallClient)
	//admin.Get("/waitClients", internal.QueryClientWaitingOfTicketCallingMachine)
	//admin.Get("/passClients", internal.QueryClientPassOfTicketCallingMachine)
	//admin.Post("/callNumber", internal.AdminSetNewClientBeenCalled)
	//admin.Post("/callNumbers", internal.AdminSetManyClientBeenCalled)
	//admin.Post("/callToPass", internal.AdminSetLineUpCallToPass)
	//admin.Post("/finishQueue", internal.AdminSetLineUpTerminal)
	//admin.Post("/cancelCall", internal.AdminSetLineUpToWait)
	//admin.Get("/carStatus", internal.CarStatusOfArea)

	admin.Get("/readReserverForOneDay", internal.AdminReadOneDayReserver)
	admin.Post("/addSomeReserver", internal.AdminCreateEmptyReserve)
	admin.Post("/addMultipleReserver", internal.AdminCreateManyEmptyReserverForOneDay)
	admin.Post("/delEmptyReserver", reserver.MiddlewareFindReserver, internal.AdminDelEmptyReserver)
	admin.Get("/haveReserverInOneMonth", internal.SimpleReserverInfoForOneMonth)
}

// 合作伙伴在手机端的功能
func userInMobile(mobile fiber.Router) {
	mobile.Use("/", dep_jwt.VerifyUserForNext, user.RequiredUserLogin)
	mobile.Use("/doILogined", func(c *fiber.Ctx) error {
		return c.JSON(serverCommon.MakeSuccessJson("ok"))
	})
	mobile.Get("/simpleInformation", internal.ReadMySimpleInfo)
	mobile.Get("/isStudentNotBindedAnything", client.MiddleWareFindClientByID, internal.ExamStudentCanBeenBind)
	mobile.Get("/allStaffSimpleInformationForOneSchool", internal.SimplePersonInfoOfSchool)
	mobile.Post("/staffBindClient", client.MiddleWareFindClientByID, internal.BindStudent)

}

func superAdmin(superAdmin fiber.Router) {
	superAdmin.Use("/", dep_jwt.VerifyUserForNext, user.RequiredUserLogin)

	superAdmin.Use("/", user.IsSuperAdmin)

	superAdmin.Post("/updateInstitution", internal.UpdateInstitution)
	// 管理系统管理员
	superAdmin.Post("/updateSystemAdmin", internal.CreateSuperAdmin)
	superAdmin.Get("/exploreSystemAdmin", internal.ExploreAdmin)

}
